package com.yida.gwj.oracle.basic.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.yida.gwj.oracle.basic.domain.House;
import com.yida.gwj.oracle.basic.mapper.HouseMapper;
import com.yida.gwj.oracle.basic.service.IHouseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.yida.gwj.oracle.basic.domain.table.HouseTableDef.HOUSE;

/***
 * @title eda
 * @description <TODO description class purpose>
 * @author eda
 * @version 1.0.0
 * @create 2021/9/16 9:32
 **/
@Service
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements IHouseService {

    @Resource
    private HouseMapper houseMapper;

    /**
     * 获取房屋数量
     *
     * @param sfyx   是否有效
     * @param zrzbsm 楼栋标识码
     * @return /
     */
    @Override
    public Long getCount(Integer sfyx, Long zrzbsm) {
        QueryWrapper wrapper = query().where(HOUSE.S_F_Y_X.eq(sfyx)).and(HOUSE.Z_R_Z_B_S_M.eq(zrzbsm));
        return this.count(wrapper);
    }

    /**
     * 获取房屋数量
     *
     * @param sfyx   是否有效
     * @param zrzbsm 楼栋标识码
     * @param ghty   用途
     * @return /
     */
    @Override
    public Long getCount(Integer sfyx, Long zrzbsm, String ghty) {
        return houseMapper.selectCountByGhyt(ghty.split(","), sfyx, zrzbsm);
    }

}
